<#include "/common/layout.html"> 
<@layout title="123">
<script type="text/javascript" src="/js/easyui/easyui_grid.js"></script>
<script type="text/javascript">
var model_name = "/vestItem";
var model_title="项目";
var types=["晒图","抽奖","投票"];
var datagrid;
	$(function() {
		datagrid=$('#product_type_table').datagrid({
		 	url:model_name+'/grid',
		 	rownumbers:true,
		 	columns:[[    
		        {field:'type',title:'forumid',formatter:function(value,row,index){
		        	return types[value];
		        }},
		        {field:'forumid',title:'forumid'},
		        {field:'forumName',title:'forumName'},
		        {field:'username',title:'username'},
		        {field:'activity',title:'activity'},
		        {field:'vest_num',title:'每次投票数'},
		        {field:'vest_line',title:'目前投票行数'},
		        {field:'like_num',title:'关注数'},
		        {field:'remark',title:'备注'},
		        {field:'id',title:'操作',width:210,
			        formatter:function(value,row,index){
			        	var restr="";
			        	restr+= "<a href='#' onclick='vote("+value+",1)'  class='linkbutton' icon='icon-reload' >投票</a>";
		        		restr+="<a href='#' onclick='vote("+value+",2)'  class='linkbutton' icon='icon-reload' >关注</a>";
		        		return restr;
			        }}
		    ]],
		    onDblClickRow:null,
		    onLoadSuccess:function(data){
				$(".linkbutton").linkbutton();
			},
		})
	})
	function vote(id_,type) {
		
		var url="";
		if(type&&type==1) url="/vestItem/vote/"+id_;
		else url="/vestItem/like/"+id_;
		
		$.messager.progress({
			text:'后台运行中....',
			interval:100
		});
		
		$.messager.confirm('请确认', '确认操作？', function(r) {
			if (r) {
				$.ajax({
					url : url,
					dataType : 'json',
					success : function(r) {
						$.messager.progress('close');
						datagrid.datagrid('load');
						datagrid.datagrid('unselectAll');
						if (r.success) {
							$.messager.show({
								msg:r.msg,
								title:'提示',
								timeout:0
							});
							editRow = undefined;
						} else {
							$.messager.alert("操作错误",r.msg,'error');
						}
					}
				});
			}
			else 
				$.messager.progress('close');
		});
		
}
	
</script>
<script type="text/javascript" src="/js/easyui/easyui_grid_common.js"></script>
</head>
	<#include "/common/seach.html" />
	<@seach tableid="product_type_table">
	<td>名称</td>
	<td><input type="text" name="seachLike_name"></td>
	<td>状态</td>
	<td><input type="text" name="seach_status"></td>
	</@seach>
</@layout>